﻿using System;

namespace Zive.Color {

    public class RgbColorSpaceChannelInfoCollection: ColorSpaceChannelInfoCollection {

        //
        // Interface
        //

        internal RgbColorSpaceChannelInfoCollection( ) { }

        public override ColorSpaceChannelInfo this[ int index ] {
            get { return _channelInfoCollection[ index ]; }
        }

        //
        // Implementation
        //

        private class RgbColorSpaceChannelInfo: ColorSpaceChannelInfo<RgbChannels> {

            public RgbColorSpaceChannelInfo( RgbChannels channel, string name ) {
                _channel = channel;
                _name = name;
            }

            public override RgbChannels Value {
                get { return _channel; }
            }

            public override int IntegerValue {
                get { return (int) _channel; }
            }

            public override string Name {
                get { return _name; }
            }

            public override double MinimumValue {
                get { return 0d; }
            }

            public override double MaximumValue {
                get { return 255d; }
            }

            public override double Range {
                get { return 255d; }
            }

            private readonly RgbChannels _channel;
            private readonly string _name;

        }

        private static readonly ColorSpaceChannelInfo<RgbChannels>[ ] _channelInfoCollection = {
            new RgbColorSpaceChannelInfo( RgbChannels.R, "R" ),
            new RgbColorSpaceChannelInfo( RgbChannels.G, "G" ),
            new RgbColorSpaceChannelInfo( RgbChannels.B, "B" ),
        };

    }

    public class RgbColorSpaceInfo: ColorSpaceInfo<RgbColor> {

        //
        // Interface
        //

        public override string Name {
            get { return "RGB"; }
        }

        public override string Label {
            get { return "RGB"; }
        }

        public override int NumberOfChannels {
            get { return 3; }
        }

        public override Type ColorType {
            get { return typeof( RgbColor ); }
        }

        public override Type ChannelsType {
            get { return typeof( RgbChannels ); }
        }

        public override Type ConverterType {
            get { return typeof( RgbColorConverter ); }
        }

        public override ColorSpaceChannelInfoCollection Channels {
            get { return _channelInfoCollection; }
        }

        public override RgbColor CreateColorInstance( ) {
            return new RgbColor( );
        }

        //
        // Implementation
        //

        private static readonly ColorSpaceChannelInfoCollection _channelInfoCollection = new RgbColorSpaceChannelInfoCollection( );

    }

}
